package leetcode.weekly.week340;

import java.util.ArrayList;
import java.util.List;

//Solution1Test
public class Solution1 {

	public boolean isPrime(int num) {
		if (num == 2) {
			return true;
		}
		if (num == 1 || num % 2 == 0) {
			return false;
		}
		for (int i = 3; i * i <= num; i += 2) {
			if (num % i == 0 || i * i == num) {
				return false;
			}
		}
		return true;
	}

	public int diagonalPrime(int[][] nums) {
		int n = nums.length;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int a = nums[i][i], b = nums[i][n - i - 1];
			if (this.isPrime(a)) {
				ans = Math.max(ans, a);
			}
			if (this.isPrime(b)) {
				ans = Math.max(ans, b);
			}
		}
		return ans;
	}
}
